package hongcaosp.app.android.user.collect;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import hongcaosp.app.android.R;
import hongcaosp.app.android.common.BaseHolder;
import hongcaosp.app.android.modle.bean.IVideo;
import xlj.lib.android.base.view.OnRecycleItemClickListener;

public class CollectHolder extends BaseHolder<IVideo> {
    private Context context;
    private ImageView phIV;
    private TextView playCountTV;

    private int type;

    public CollectHolder(Context context,View itemView, int type, OnRecycleItemClickListener recycleItemClickListener) {
        super(itemView, recycleItemClickListener);
        this.context = context;
        this.type = type;
        phIV = itemView.findViewById(R.id.place_holder);
        playCountTV = itemView.findViewById(R.id.play_count);
    }

    public CollectHolder(Context context, View itemView, int type) {
        super(itemView);
        this.context = context;
        this.type = type;
        phIV = itemView.findViewById(R.id.place_holder);
        playCountTV = itemView.findViewById(R.id.play_count);
    }

    @Override
    public void setData(IVideo favorite) {
        Glide.with(context).load(favorite.getVideoImage()).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(phIV);
        if (type == 1) {
            playCountTV.setText(favorite.getPlayCount() + "");
        } else {
            playCountTV.setText(favorite.getLikeCount() + "");
        }
    }
}
